all files / iconButton/ iconButton.vue

43.48% Statements 10/23
100% Branches 4/4
10% Functions 1/10
23.53% Lines 4/17
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98                        1× 1× 1×                                                                                                                                                                      
//
//
//
//
//
//
//
//
//
//
//
 
import abstractButton from '../internal/abstractButton'
import icon from '../icon'
import tooltip from '../tooltip'
export default {
  name: 'mu-icon-button',
  props: {
    icon: {
      type: String
    },
    iconClass: {
      type: String,
      default: ''
    },
    href: {
      type: String,
      default: ''
    },
    target: {
      type: String
    },
    disabled: {
      type: Boolean,
      default: false
    },
    keyboardFocused: {
      type: Boolean,
      default: false
    },
    tooltip: {
      type: String
    },
    tooltipPosition: {
      type: String,
      default: 'bottom-center'
    },
    touch: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    verticalPosition () {
      const tooltipPosition = this.tooltipPosition.split('-')
      return tooltipPosition[0]
    },
    horizontalPosition () {
      const tooltipPosition = this.tooltipPosition.split('-')
      return tooltipPosition[1]
    }
  },
  data () {
    return {
      tooltipShown: false,
      tooltipTrigger: null
    }
  },
  methods: {
    handleClick (e) {
      this.$emit('click', e)
    },
    handleHover (event) {
      this.tooltipShown = true
      this.$emit('hover', event)
    },
    handleHoverExit (event) {
      this.tooltipShown = false
      this.$emit('hoverExit', event)
    },
    handleKeyboardFocus (isFocus) {
      this.$emit('keyboardFocus', isFocus)
    },
    handleStop (event) {
      event.stopPropagation() // 防止list中使用导致波纹点击重复
    }
  },
  mounted () {
    this.tooltipTrigger = this.$el
  },
  components: {
    'abstract-button': abstractButton,
    icon,
    tooltip
  }
}